home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / python2.4 / idlelib / FileList.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2005-10-18  |  4KB  |  151 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.4)
  3.  
  4. import os
  5. from Tkinter import *
  6. import tkMessageBox
  7.  
  8. class FileList:
  9.     from EditorWindow import EditorWindow
  10.     
  11.     def __init__(self, root):
  12.         self.root = root
  13.         self.dict = { }
  14.         self.inversedict = { }
  15.         self.vars = { }
  16.  
  17.     
  18.     def open(self, filename, action = None):
  19.         filename = self.canonize(filename)
  20.         if os.path.isdir(filename):
  21.             tkMessageBox.showerror('File Error', '%r is a directory.' % (filename,), master = self.root)
  22.             return None
  23.         
  24.         key = os.path.normcase(filename)
  25.         if self.dict.has_key(key):
  26.             edit = self.dict[key]
  27.             edit.top.wakeup()
  28.             return edit
  29.         
  30.         if action:
  31.             return action(filename)
  32.         else:
  33.             return self.EditorWindow(self, filename, key)
  34.  
  35.     
  36.     def gotofileline(self, filename, lineno = None):
  37.         edit = self.open(filename)
  38.         if edit is not None and lineno is not None:
  39.             edit.gotoline(lineno)
  40.         
  41.  
  42.     
  43.     def new(self, filename = None):
  44.         return self.EditorWindow(self, filename)
  45.  
  46.     
  47.     def close_all_callback(self, event):
  48.         for edit in self.inversedict.keys():
  49.             reply = edit.close()
  50.             if reply == 'cancel':
  51.                 break
  52.                 continue
  53.         
  54.         return 'break'
  55.  
  56.     
  57.     def close_edit(self, edit):
  58.         
  59.         try:
  60.             key = self.inversedict[edit]
  61.         except KeyError:
  62.             print "Don't know this EditorWindow object.  (close)"
  63.             return None
  64.  
  65.         if key:
  66.             del self.dict[key]
  67.         
  68.         del self.inversedict[edit]
  69.         if not self.inversedict:
  70.             self.root.quit()
  71.         
  72.  
  73.     
  74.     def filename_changed_edit(self, edit):
  75.         edit.saved_change_hook()
  76.         
  77.         try:
  78.             key = self.inversedict[edit]
  79.         except KeyError:
  80.             print "Don't know this EditorWindow object.  (rename)"
  81.             return None
  82.  
  83.         filename = edit.io.filename
  84.         if not filename:
  85.             if key:
  86.                 del self.dict[key]
  87.             
  88.             self.inversedict[edit] = None
  89.             return None
  90.         
  91.         filename = self.canonize(filename)
  92.         newkey = os.path.normcase(filename)
  93.         if newkey == key:
  94.             return None
  95.         
  96.         if self.dict.has_key(newkey):
  97.             conflict = self.dict[newkey]
  98.             self.inversedict[conflict] = None
  99.             tkMessageBox.showerror('Name Conflict', 'You now have multiple edit windows open for %r' % (filename,), master = self.root)
  100.         
  101.         self.dict[newkey] = edit
  102.         self.inversedict[edit] = newkey
  103.         if key:
  104.             
  105.             try:
  106.                 del self.dict[key]
  107.             except KeyError:
  108.                 pass
  109.             except:
  110.                 None<EXCEPTION MATCH>KeyError
  111.             
  112.  
  113.         None<EXCEPTION MATCH>KeyError
  114.  
  115.     
  116.     def canonize(self, filename):
  117.         if not os.path.isabs(filename):
  118.             
  119.             try:
  120.                 pwd = os.getcwd()
  121.             except os.error:
  122.                 pass
  123.  
  124.             filename = os.path.join(pwd, filename)
  125.         
  126.         return os.path.normpath(filename)
  127.  
  128.  
  129.  
  130. def _test():
  131.     fixwordbreaks = fixwordbreaks
  132.     import EditorWindow
  133.     import sys as sys
  134.     root = Tk()
  135.     fixwordbreaks(root)
  136.     root.withdraw()
  137.     flist = FileList(root)
  138.     if sys.argv[1:]:
  139.         for filename in sys.argv[1:]:
  140.             flist.open(filename)
  141.         
  142.     else:
  143.         flist.new()
  144.     if flist.inversedict:
  145.         root.mainloop()
  146.     
  147.  
  148. if __name__ == '__main__':
  149.     _test()
  150.  
  151.